FROM java:openjdk-8-jre-alpine
MAINTAINER 王斌 <w.billy@qq.com>

ARG MIRROR=http://mirror.bit.edu.cn/apache
ARG VERSION=3.4.9

LABEL name="zookeeper" version=$VERSION
RUN echo "http://mirrors.aliyun.com/alpine/alpine/v3.4/main" > /etc/apk/repositories \
    && echo "http://mirrors.aliyun.com/alpine/alpine/v3.4/community" >> /etc/apk/repositories \
    && apk update \

RUN apk add --no-cache wget bash \
    && mkdir /opt \
    && wget -q -O - $MIRROR/zookeeper/zookeeper-$VERSION/zookeeper-$VERSION.tar.gz | tar -xzf - -C /opt \
    && mv /opt/zookeeper-$VERSION /opt/zookeeper \
    && cp /opt/zookeeper/conf/zoo_sample.cfg /opt/zookeeper/conf/zoo.cfg \
    && mkdir -p /tmp/zookeeper

EXPOSE 2181 2888 3888

WORKDIR /opt/zookeeper

VOLUME ["/opt/zookeeper/conf", "/tmp/zookeeper"]
ADD run.sh /opt/zookeeper.sh

CMD ["/opt/zookeeper.sh"]
